﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YJKSparseDisOfRoom.ModelLayer
{
	public class CurveBeanUnit
	{
		public List<BaseCurveBean> LstCurve
		{
			get
			{
				return this.m_lstCurve;
			}
			private set
			{
				this.m_lstCurve = value;
			}
		}

		public List<Curve> LstInnerLinkCurve
		{
			get
			{
				return this.m_lstInnerLinkCurve;
			}
			private set
			{
				this.m_lstInnerLinkCurve = value;
			}
		}

		public bool CurveTag
		{
			get
			{
				return this.m_bIfCalculateInnerCurveTag;
			}
			set
			{
				this.m_bIfCalculateInnerCurveTag = value;
			}
		}

		public CurveBeanUnit(List<BaseCurveBean> lstInputCurveBean, bool ifCalculateInner)
		{
			this.m_lstCurve = lstInputCurveBean;
			this.m_bIfCalculateInnerCurveTag = ifCalculateInner;
			if (this.m_bIfCalculateInnerCurveTag)
			{
				this.CalculateInnerCurves();
			}
		}

		private void CalculateInnerCurves()
		{
			List<XYZ> list = new List<XYZ>();
			if (this.CurveTag)
			{
				foreach (BaseCurveBean baseCurveBean in this.m_lstCurve)
				{
					list.Add(baseCurveBean.ThisCurve.GetEndPoint(0));
				}
				for (int i = 0; i < list.Count; i++)
				{
					int num = i - 1;
					int num2 = i + 1;
					if (num < 0)
					{
						num = list.Count - 1;
					}
					if (num2 > list.Count - 1)
					{
						num2 = 0;
					}
					for (int j = i + 1; j < list.Count; j++)
					{
						if (j != i && j != num && j != num2)
						{
							Line item = Line.CreateBound(list[i], list[j]);
							this.LstInnerLinkCurve.Add(item);
						}
					}
				}
			}
		}

		private List<BaseCurveBean> m_lstCurve = new List<BaseCurveBean>();

		private List<Curve> m_lstInnerLinkCurve = new List<Curve>();

		private bool m_bIfCalculateInnerCurveTag;
	}
}
